package com.xiaohao.student_course.service;

import com.xiaohao.student_course.bean.Classes;
import com.xiaohao.student_course.dao.ClassesDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @author 小浩
 * @date 2018-12-16 17:31
 * @package com.xiaohao.student_course.service
 * @description
 */
@Service
public class ClassesService {
    @Autowired
    private ClassesDao classesDao;

    public List<Classes> getClassesByMajor(String majorname){
        Classes classes = new Classes();
        classes.setMajorName(majorname);
        return classesDao.findAll(Example.of(classes, ExampleMatcher.matching().withIgnoreNullValues()));
    }
    public List<Classes> getAllClasses(){
        return classesDao.findAll();
    }
}
